--准时下班
local zhunshixiaban = fk.CreateSkill {
    name = "mcdh_zhunshixiaban",
    tags = {Skill.Compulsory},
    on_acquire = function(self, player)
        local room = player.room
        local count = 0
        room.logic:getEventsOfScope(GameEvent.UseCard, 1, function(evt)
            if evt.data[1].from == player.id then
                count = count + 1
            end
            return false
        end, Player.HistoryTurn)
        room:setPlayerMark(player,"@[mcdh_zhunshixiaban]",count)
    end
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

Fk:addQmlMark{
    name = "mcdh_zhunshixiaban",
    qml_path = "",
    how_to_show = function(name, value, p)
        if Fk:currentRoom().current == p then

        else
            return "#hidden"
        end
    end,
}

zhunshixiaban:addEffect(fk.CardUsing,{
    can_trigger = function(self, event, target, player, data)
        local room = player.room
        if not player:hasSkill(self) or target ~= player then return false end
        if room.current == player then
            local count = 0
            player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function(evt)
                if evt.data[1].from == player.id then
                    count = count + 1
                end
                return false
            end, Player.HistoryTurn)
            return count == player.hp
        end
        return false
    end,
    on_use = function(self, event, target, player, data)
        player:drawCards(2, self.name)
        player:skip(Player.Discard)
    end,
})

zhunshixiaban:addEffect(fk.CardUsing,{
    can_refresh = function (self, event, target, player, data)
        local room = player.room
        return target == player and player:hasSkill(self,true) and room.current == player
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        room:addPlayerMark(player, "@[mcdh_zhunshixiaban]-turn", 1)
    end,
})

zhunshixiaban:addEffect('prohibit',{
    prohibit_use = function(self, player)
        return player:hasSkill(self.name) and player:getMark("@[mcdh_zhunshixiaban]-turn") <= player.hp
    end,
})

Fk:loadTranslationTable {
    ["mcdh_zhunshixiaban"] = "职毕",
    [":mcdh_zhunshixiaban"] = "『准时下班』<br>锁定技，你的回合内：你至多使用X+1张牌；当你使用第X张牌时，你摸两张牌，跳过本回合下个弃牌阶段。（X为你的体力值）",

    ["#mcdh_zhunshixiaban_prohibit"] = "已下班-",
    ["@mcdh_zhunshixiaban-phase"] = "状态",
    ["@mcdh_zhunshixiaban_count-phase"] = "可用牌数：",
}

return zhunshixiaban